﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using QLTV_Public;

namespace QLTV_Data
{
   public class CT_PhieuYeuCau_Data
    {
        KetNoiCSDL_Data kn = new KetNoiCSDL_Data();
        public DataTable TaoBang(string sql)
        {
            return kn.taobang(sql);
        }
        public DataTable LayDuLieu()
        {
            return kn.LayDuLieu("");
        }
        public DataTable Load_GhiTra_GiaoVien(string soCaBiet)
        { 
            int Npara=1;
            string[] name = new string[Npara];
            object[] values = new object[Npara];
            name[0] = "@SoCaBiet";
            values[0] = soCaBiet;
            return kn.LayDuLieu("Load_GhiTra_GiaoVien",name,values,Npara);
        }
        public DataTable Load_GhiTra_HocVien(string soCaBiet)
        { 
            int Npara=1;
            string[] name = new string[Npara];
            object[] values = new object[Npara];
            name[0] = "@SoCaBiet";
            values[0] = soCaBiet;
            return kn.LayDuLieu("Load_GhiTra_HocVien", name, values, Npara);
        }
        public DataTable Load_TaiLieu_GhiTra(string maDocGia)
        {
            int Npara = 1;
            string[] name = new string[Npara];
            object[] values = new object[Npara];
            name[0] = "@MaDocGia";
            values[0] = maDocGia;
            return kn.LayDuLieu("Load_TaiLieu_GhiTra", name, values, Npara);
        }
        public DataTable Load_LichSuMuon(string maDocGia)
        {
            int Npara = 1;
            string[] name = new string[Npara];
            object[] values = new object[Npara];
            name[0] = "@MaDocGia";
            values[0] = maDocGia;
            return kn.LayDuLieu("Load_LichSuMuon", name, values, Npara);
        }
        public int Insert(CT_PhieuYeuCau_Public ct)
        {
            int nParameter =7;
            string[] name = new string[nParameter];
            object[] value = new object[nParameter];
            name[0] = "@MaPhieuYC";
            value[0] = ct.MaPhieuYC;
            name[1] = "@SoCaBiet";
            value[1] = ct.SoCaBiet;
            name[2] = "@NgayMuon";
            value[2] = ct.NgayMuon;
            name[3] = "@NgayDuTra";
            value[3] = ct.NgayDuTra;
            name[4] = "@TrangThaiGiaHan";
            value[4] = ct.TrangThaiGiaHan;
            name[5] = "@TrangThaiMuon";
            value[5]=ct.TrangThaiMuon;
            name[6] = "@MaNhanVien";
            value[6] = ct.MaNhanVien1;
            return kn.update("Insert_CT_PhieuYeuCau",name,value,nParameter);
        }
        public DataTable Load_ChiTiet_Muon(string maPhieu)
        {
            int Npara = 1;
            string[] name = new string[Npara];
            object[] value = new object[Npara];
            name[0] = "@MaPhieuYC";
            value[0] = maPhieu;
            return kn.LayDuLieu("Load_ChiTiet_Muon",name,value,Npara);
        }
        public int Update_GhiTra(CT_PhieuYeuCau_Public obj)
        {
            int Npara = 5;
            string[]name=new string[Npara];
            object[] value = new object[Npara];
            name[0] = "@MaPhieuYC";
            value[0] = obj.MaPhieuYC;
            name[1] = "@SoCaBiet";
            value[1] = obj.SoCaBiet;
            name[2] = "@NgayTra";
            value[2] = obj.NgayTra;
            name[3] = "@TrangThaiMuon";
            value[3] = obj.TrangThaiMuon;
            name[4] = "@MaNhanVien";
            value[4] = obj.MaNhanVien1;
            return kn.update("Update_GhiTra",name,value,Npara);

        }
        public int Update_GiaHan(CT_PhieuYeuCau_Public obj)
        {
            int Npara = 5;
            string[] name = new string[Npara];
            object[] value = new object[Npara];
            name[0]="@MaPhieuYC";
            value[0] = obj.MaPhieuYC;
            name[1] = "@SoCaBiet";
            value[1] = obj.SoCaBiet;
            name[2] = "@NgayDuTra";
            value[2] = obj.NgayDuTra;
            name[3] = "@TrangThaiGiaHan";
            value[3] = obj.TrangThaiGiaHan;
            name[4] = "@MaNhanVien";
            value[4] = obj.MaNhanVien1;

            return kn.update("Update_GiaHan",name,value,Npara);
        }
    }
}
